//index.js

const {
  API
} = require("../../utils/api");

//获取应用实例
const app = getApp()

Page({
  data: {},

  onShow: async function () {
    const globalData = app.globalData;
    if (!globalData.user) {
      let user;
      try {
        user = (await API.getUserInfo()).data;
      } catch (e) {
        console.log('未登录或登录态失效，重新登录...');
        user = await API.login();
      }
      app.globalData.user = user;
      if (!(user && user.shuVerify)) {
        wx.navigateTo({
          url: '/pages/verify/verify',
        });
      }
    } else if (!globalData.user.shuVerify) {
      wx.navigateTo({
        url: '/pages/verify/verify',
      });
    }
  },
})